<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>收入</title>
    <link rel="stylesheet" href="../../layui-v2.6.8/layui/css/layui.css">
    <script type="text/javascript" src="../../layui-v2.6.8/layui/layui.js"></script>
    <script type="text/javascript" src="../../js/jQuery%20v3.6.0.js"></script>
    <script type="text/javascript" src="../../js/echarts.min.js"></script>
</head>
<body>
<div id="container" style="width: 600px;height:400px;"></div>
<script type="text/javascript">
    var dom = document.getElementById("container");
    var myChart = echarts.init(dom);
    var app = {};

    var option;

    $.get("http://localhost:8080/search",function (data){
        myChart.hideLoading();
        myChart.setOption({
            xAxis: {
                data: data.categories
            },
            series: [{
                // 根据名字对应到相应的系列
                name: '月收入',
                data: data.data,
                markPoint: {
                    data: [
                        {type: 'max', name: '最大值'},
                        {type: 'min', name: '最小值'}
                    ]
                },
                markLine: {
                    data: [
                        {type: 'average', name: '平均值'}
                    ]
                }
            }]
        });
    })

    // 初始 option
    option = {
        title: {
            text: '月收入'
        },
        tooltip: {
            trigger: 'axis'
        },
        // legend: {
        //     data:['月收入']
        // },
        xAxis: {
            data: []
        },
        yAxis: {},
        series: [{
            name: '月收入',
            type: 'line',
            data: []
        }]
    };
    myChart.showLoading();
    if (option && typeof option === 'object') {
        myChart.setOption(option);
    }
</script>
</body>
</html>